export const generatedColumns = vm => {
  return [
    {
      title: "类型编号",
      key: "type",
      align: "center"
    },
    {
      title: "名称",
      key: "name",
      align: "center"
    },
    {
      title: "创建时间",
      align: "center",
      render: (h, params) => {
        const { createdAt } = params.row
        return h("span", vm.moment(createdAt).format("YYYY/MM/DD HH:mm:ss"))
      }
    },
    {
      title: "操作",
      align: "center",
      render: (h, params) => {
        const row = JSON.parse(JSON.stringify(params.row))
        return h(
          "Poptip",
          {
            props: {
              confirm: true,
              title: "您确定要删除这条数据吗?",
              transfer: true,
              cancelText: "取消"
            },
            on: {
              "on-ok": () => vm.handleDelete(row)
            }
          },
          [
            h(
              "Button",
              {
                props: {
                  type: "error",
                  size: "small"
                }
              },
              "删除"
            )
          ]
        )
      }
    }
  ]
}

export const rules = () => {
  return {
    name: [
      {
        required: true,
        message: "请输入设备类型名称"
      }
    ],
    type: {
      required: true,
      type: "number",
      message: "请输入类型编号",
      trigger: "blur"
    },
    seriesId: [
      {
        required: true,
        message: "请选择设备类别"
      }
    ]
  }
}
